//#include<stdio.h>
/* #define ONE 1
#define TWO (1<<1)
#define THREE (1<<2)
#define FOUR (1<<3)
#define FIVE (1<<4)
 
void Print(int flag)
{
    if(flag & ONE) printf("1\n");
    if(flag & TWO) printf("2\n");
    if(flag & THREE) printf("3\n");
    if(flag & FOUR) printf("4\n");
    if(flag & FIVE) printf("5\n");
}
 
int main()
{
    Print(ONE);
    printf("----------------------\n");
    Print(TWO);
    printf("----------------------\n");
    Print(ONE|TWO);
    printf("----------------------\n");
    Print(THREE|FOUR|FIVE);
    printf("----------------------\n");
    Print(ONE|TWO|THREE|FOUR|FIVE);
} */

// #include <stdio.h>
// #include <string.h>
// #include <unistd.h>
// #include <sys/types.h>
// #include <sys/stat.h>
// #include <fcntl.h>
/* int main()
{
	int fd = open("log.txt", O_WRONLY | O_CREAT, 0666);
	if (fd < 0)
    {
		perror("open");
		return 1;
	}
    printf("fd:%d\n",fd);
	const char* str = "hello\n";
	for (int i = 0; i < 10; i++)
    {
		write(fd, str, strlen(str));
	}
	close(fd);
	return 0;
} */


// int main()
// {
//     close(1);//关闭标准输出流
//     open("log.txt", O_WRONLY|O_CREAT|O_TRUNC, 0666);
//     printf("hello linux\n");
// }

// int main()
// {
//     int fd = open("log.txt", O_WRONLY|O_CREAT|O_TRUNC, 0666);
//     dup2(fd, 1);
//     printf("hello linux\n");
//     return 0;
// }




#include <stdio.h>
#include<unistd.h>
#include <string.h>
int main()
{
    const char *s1="hello write\n";
    const char *s2="hello fprintf\n";
    const char *s3="hello fwrite\n";\
    write(1,s1,strlen(s1));
    fprintf(stdout,"%s", s2);
    fwrite(s3, strlen(s3), 1, stdout);
    fork();
    return 0;
}